NameError: name 'S' is not defined